<?php
/* @var $this PurchaseOrderHeaderController */
/* @var $model PurchaseOrderHeader */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'purchase-order-header-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>true,
)); 

$quo_no=isset($quo_no)?$quo_no:$model->quotation_no;

?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'purchase_no'); ?>
		<?php echo $form->textField($model,'purchase_no',array('id'=>'purchase_no','value'=>$purNo,'size'=>50,'readonly'=>'readonly')); ?>
		<?php //echo $form->error($model,'purchase_no'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'quotation_no'); ?>
		<?php $this->widget('ext.yii-easyui.widgets.EuiCombogrid', array(
			'id'=>'quotation_no',
			//'name'=>'quotation_no',			
			'style' => 'width: 220px',
			'panelWidth' => 450,
			'pagination' => true,
			'url' => $this->createUrl('quo'),
			'idField' => 'quotation_no',
			'textField' => 'quotation_no',
			'columns' => array(
				array('title' => 'Quotation No.', 'field'=>'quotation_no', 'width'=> 20, 'sortable'=>true),
				array('title' => 'Customer', 'field'=>'customer', 'width'=> 30, 'sortable'=>true),
				array('title' => 'Project', 'field'=>'project', 'width'=> 20, 'sortable'=>true),
			)	
		)); 
		?>
		<?php echo $form->hiddenField($model,'quotation_no',array('id'=>'quo_no','value'=>$quo_no)); ?>
		<?php //echo $form->error($model,'quotation_no'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'vendor_id'); ?>
		<?php
			if(isset($model->vendor_id)){
				echo CHtml::textField('vendorLabel',$vendorLabel,array('readonly'=>'readonly'));
				echo $form->hiddenField($model,'vendor_id',array());
			}else if(isset($vendorId)){
				echo CHtml::textField('vendorLabel',$vendorLabel,array('readonly'=>'readonly'));
				echo $form->hiddenField($model,'vendor_id',array('value'=>$vendorId));
			}else{
				$this->widget('ext.combobox.EJuiComboBox', array(
	                'model' => $model,
	                'attribute' => 'vendor_id',
	                'data' => CHtml::listData(Vendor::model()->findAll(),'id','vendor'),
	                //'data' => CHtml::listData(Vendor::model()->with('products','products.quotationDetail')->findAll('id=vendor_id and products.product_pn=quotationDetail.product_pn and quotation_no=:quotation_no',array('quotation_no'=>$quo_no)),'id','vendor'),
	                'options' => array(
	                   //'allowText' => false,
	                   'disable'=>true, 
	                ),
	                'htmlOptions' => array('size' => 10,'disable'=>true,),
	            ));
	        }
         ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'datePO'); ?>
		<?php //echo $form->textField($model,'datePO',array('value'=>date("Y-m-d"),'readonly'=>'readonly')); ?>
		<?php
        $this->widget('zii.widgets.jui.CJuiDatePicker',
              array(
                  'attribute'=>'datePO',
                  'language'=>'en',
                  'model'=>$model,
                  'options'=>array('mode'=>'focus',
                                   'dateFormat'=>'yy-mm-dd',
                                   'showAnim'=>'slideDown',),
                  'htmlOptions'=>array('size'=>'30','class'=>'datePO'),));

        ?>
		<?php //echo $form->error($model,'datePO'); ?>
	</div>

	<div class="row">
        <?php echo $form->labelEx($model,'currency'); ?>
        <?php echo $form->dropDownList($model,'currency',array('USD'=>'USD','IDR'=>'IDR')); ?>
        <?php //echo $form->error($model,'currency'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'attention'); ?>
        <?php echo $form->textField($model,'attention',array('id'=>'attention','size'=>40,'maxlength'=>40)); ?>
        <?php //echo $form->error($model,'attention'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'reff'); ?>
        <?php echo $form->textField($model,'reff',array('id'=>'reff','size'=>40,'maxlength'=>40)); ?>
        <?php //echo $form->error($model,'attention'); ?>
    </div>

	<div class="row">
		<?php echo $form->labelEx($model,'terms'); ?>
		<?php echo $form->textField($model,'terms',array('size'=>30,'maxlength'=>30)); ?>
		<?php //echo $form->error($model,'terms'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'payment_term'); ?>
		<?php echo $form->textField($model,'payment_term',array('size'=>40,'maxlength'=>40)); ?>
		<?php //echo $form->error($model,'payment_term'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'freight'); ?>
		<?php echo $form->textField($model,'freight',array('size'=>20,'maxlength'=>20)); ?>
		<?php //echo $form->error($model,'freight'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'eta'); ?>
		<?php echo $form->numberField($model,'eta',array('value'=>1,'min'=>1,'max'=>100)); ?>
		<?php //echo $form->error($model,'eta'); ?>

		<?php /*$this->widget('zii.widgets.jui.CJuiDatePicker',array(
			'model'=>$model,
        	'attribute'=>'eta',
		    //'name'=>'eta',
		    // additional javascript options for the date picker plugin
		    'options'=>array(
		        'showAnim'=>'fold',
		    ),
		    'htmlOptions'=>array(
		        'style'=>'height:20px;'
		    ),
		)); */?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'special_instruction'); ?>
		<?php echo $form->textArea($model,'special_instruction',array('rows'=>6, 'cols'=>50)); ?>
		<?php //echo $form->error($model,'special_instruction'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('id'=>'submitBtn')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->